// 用户管理路由
const express = require('express');
const routerMenu = express.Router();
// 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
    // 导入需要验证的规则对象
const reg_schema = require('../schema/schema')
const handle = require('../router_handler/users');
// 用户列表
routerMenu.get('/users', handle.getUsers);
// 添加用户
routerMenu.post('/users', expressJoi(reg_schema.user_create_schema, handle, handle.addusers));
// 根据id查询用户信息
routerMenu.get('/users/:id', handle.search);
// 修改用户状态
routerMenu.put('/users/:uId/state/:type', handle.changeState);
// 编辑用户提交
routerMenu.put('/users/:id', expressJoi(reg_schema.user_update_schema, handle.update));
// 删除单个用户
routerMenu.delete('/users/:id', handle.delete)
    // 分配用户角色
routerMenu.put('/users/:id/role', handle.updateRole)
module.exports = routerMenu;